<template>
  <div>
    <div class="title2 title2-padding">长指令日志</div>
    <el-table :data="logs" style="width: 100%" :max-height="maxHeight">
      <el-table-column prop="time" label="发送时间" width="180">
      </el-table-column>
      <el-table-column prop="valueList" label="发送指令" >
        <template  #default="scope">
          <span>{{ localeValue(scope.row.valueList) }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="result" label="执行结果" width="180">
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
import { useTcStore } from '@/stores/tc-module.js'
import { hexToDecimal } from '@/comm/index.js'
import {computed} from "vue";
const tcStore = useTcStore()
const logs = computed(() => tcStore.longTcLog.reverse())
const maxHeight = '600px'

const localeValue = (arr) => {
  let result = ""
  for (let i = 0; i < arr.length; i++) {
    result += hexToDecimal(arr[i]) + ", "
  }
  return  result.slice(0, -2)
}
</script>
<style scoped>
.long-tc-logs {
  min-height:240px;
  max-height:600px;
}

</style>
